#include <iostream>
using namespace std;

signed main()
{
    int m;
    cin>>m;
    for(int i=0;i<m;i++){
        int k;
        cin>>k;
        int flag = 0;
        for(int n=1;n<10;n++){
            int nk2 = n*k*k;
            int t = k;
            while(t){
                if(t%10==nk2%10){
                    t/=10;
                    nk2/=10;
                }
                else    break;
            }
            if(t==0){
                cout<<n<<" "<<n*k*k<<"\n";
                flag = 1;
                break;
            }
        }
        if(flag == 0)    cout<<"No\n";
    }
    return 0;
}
